﻿namespace Agile.Service.Admin.Model;

public partial class SysUserModel
{
    protected override async Task<string> ToLogAsync(BaseModel newBaseModel, BaseModel oldBaseModel, IServiceProvider serviceProvider)
    {
        var newModel = (SysUserModel)newBaseModel;
        var oldModel = (SysUserModel)oldBaseModel;

        var logBuilder = new LogContentBuilder();
        if (newModel.IsChanged(nameof(RealName)))
        {
            logBuilder.Append("昵称".ToLog(oldModel.RealName, newModel.RealName));
        }
        if (newModel.IsChanged(nameof(Enabled)))
        {
            logBuilder.Append("是否启用".ToLog(oldModel.Enabled ? "启用" : "禁用", newModel.Enabled ? "启用" : "禁用"));
        }
        if (newModel.IsChanged(nameof(Phone)))
        {
            logBuilder.Append("手机号".ToLog(oldModel.Phone, newModel.Phone));
        }
        if (newModel.IsChanged(nameof(Email)))
        {
            logBuilder.Append("邮箱".ToLog(oldModel.Email, newModel.Email));
        }
        if (newModel.IsChanged(nameof(Remark)))
        {
            logBuilder.Append("备注".ToLog(oldModel.Remark, newModel.Remark));
        }
        await Task.CompletedTask;
        return logBuilder.ToString();
    }
}
